package com.bruce.demo2.patterns.demo1.creational.demo02.factoryMethod.demo1;

/**
 * @PROJECT_NAME design_patterns
 * @DESCRIPTION 咖啡
 * @AUTHOR CNBruceLee
 * @DATE 2021/7/10 17:39
 */
public class CoffeeStore {

    /**
     * 点咖啡
     *
     * @param type 咖啡类型
     * @return Coffee
     */
    public Coffee orderCoffee(String type) {
        Coffee coffee = null;
        if ("american".equals(type)) {
            coffee = new AmericanCoffee();
        } else if ("latte".equals(type)) {
            coffee = new LatteCoffee();
        } else {
            throw new RuntimeException("对不起你点的咖啡没有了");
        }

        //添加配料
        coffee.addMilk();
        coffee.addSugar();
        return coffee;
    }
}
